
<?php require_once 'luottruycap2.php';   ?>
 <?php require_once 'model/db.php'; ?>

<html xmlns="http://www.w3.org/1999/xhtml">
   
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>
</head>

<body id="body">

<div id="backround">

       

    <form method="POST" id="form" action="pages.php">
        <table style=" font-family: Tahoma, Geneva, sans-serif; font-size: 12px;padding: 0px 5px 20px 0px;">
                   <tr><td>Min</td><td><input type="text" name="min" value="1" size="15"/></td></tr>
                   <tr><td>Max</td><td><input type="text" name="max"  value="100" size="15"/></td></tr>
                   <tr><td>Keyword</td><td><input type="text" name="keyword" value="cafe" size="15" /></td></tr>
                   <tr><td>numbet search:</td><td><b><?php echo mwriteLogs();?></b></td></tr>
               <tr><td><input type="submit" name="submit"  value="search" /></td></tr>
               

               </table>
              </form>
  
    
 

<?php  if (isset($_POST['submit'])) :  ?>
<?php 
$min = $_POST['min'];

$max = $_POST['max'];

$keyword = $_POST['keyword'];

?>

 
        
    
<?php  if (!empty($min) && !empty($max) && !empty($keyword)) {
      $query  = "SELECT * FROM pages
                 WHERE (likes >= $min)
                  AND   (likes <= $max)
                  AND (description LIKE '% $keyword %')
                  LIMIT 0,10";
    

$pages = getData($query);}

else { $query  = "SELECT * FROM pages 
                  LIMIT 0,10";
 echo "da tim thay 10 phan tu dau tien ";
                 $pages = getData($query);
                 echo "da tim thay 10 phan tu dau tien ";

                  }
                  
?>

    
    

<?php if (!empty($pages)): ?>
<table border ="1">
    <tr>
        <td>name</td>
        <td>likes</td>
        <td>id</td>
        <td>description</td>
        <td>piture</td>
        <td>status</td>
    </tr>
    
    
 <?php foreach ($pages as $page): ?> 
    <tr>
        <td><?php echo $page['name']; ?></td>
        <td><?php echo $page['likes']; ?></td>
        <td><?php echo $page['id']; ?></td>
        <td><?php echo substr($page['description'] ,0,100) ?></td>
        <td>  <img src="<?php echo $page['picture']; ?>"></td>
        
       <td><?php   if  ( $page['status'] =1){
                       echo " dang dung";}
                       
                       else if ($page['status'] =0){
                           echo "khong xac dinh";}
                           else { echo "chua co ";}
                            
       
?></td>    
       
    </tr>
  
    
   
    
    
    
    
 
    
    

<?php endforeach; ?>
    </table>
<?php endif; ?>
<?php endif; ?>
</div><!-- the end form -->


</body>
</html>
